﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TypeParameter.aspx.cs" Inherits="System_SysParameters_Default"
    ValidateRequest="false" MaintainScrollPositionOnPostback="true" %>

<%@ Register TagPrefix="esshs" Namespace="Titan.WebForm" Assembly="WebCalendar" %>
<%@ Register TagPrefix="UserControl" Src="~/UserControl/ComQueryControls.ascx" TagName="QueryControl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>数据显示</title>
    <link href="../../CSS/css.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript" src="../../js/JS_common.js"></script>

    <script language="javascript" type="text/javascript" src="../../js/My97DatePicker/WdatePicker.js"></script>
    <script language="javascript" type="text/javascript" src="../../js/GeneralPage.js"></script>

    <style type="text/css">
    div#detailDiv {
      border:0;
      position:absolute;
     }
    div#detailDiv table{
      border:1px solid #5077A0;
      background-color:#EFF7FF;
      position:absolute;
     }
    </style>

    <script language="javascript" type="text/javascript">
    function doDefaultAction(form) {
        if (form.btnQueryNormal) {
            form.btnQueryNormal.focus();
            form.btnQueryNormal.click();
        } else if (form.btnQueryCustom) {
            form.btnQueryCustom.focus();
            form.btnQueryCustom.click();
        }
    }
    function ExpandChildren(clickObj,childTRName)
    {
        var allTR = document.getElementById("dataTable").rows;
        var trlength = allTR.length;
        for(var i=0;i<trlength;i++)
        {
            var strObj = new String(allTR[i].getAttribute("id"));
            if(strObj.indexOf(childTRName+"_")==0)
            {
                    //展开下一级  
                if((clickObj.innerHTML=="展开") && (strObj.split('_').length == childTRName.split('_').length+1) && (allTR[i].style.display=='none'))
                {              
                    allTR[i].style.display='block';  
                }
                else if((strObj.split('_').length > childTRName.split('_').length) && (allTR[i].style.display=='block') )//收起所有子级
                {
                    allTR[i].style.display='none';    
                    var childrenArray = allTR[i].children;
                    var childrenlength = childrenArray.length;
                    
                    for(var j = 0;j< childrenlength;j++)
                    {
                        var clickA = WebForm_GetElementByTagName(childrenArray[j],"a");
                        if(clickA!=null)
                        {
                            clickA.outerHTML=clickA.outerHTML.replace(/收起/g,'展开');
                            break;
                        }
                    }
                }
             }
        }
        if(clickObj.innerHTML=="展开")
            clickObj.outerHTML=clickObj.outerHTML.replace(/展开/g,'收起');
        else if(clickObj.innerHTML=="收起")
            clickObj.outerHTML=clickObj.outerHTML.replace(/收起/g,'展开');
    }
    function ExpandAll(clickObj)
    {
        var allTR = document.getElementById("dataTable").rows;
        var trlength = allTR.length;
        for(var i=0;i<trlength;i++)
        {
            var strObj = new String(allTR[i].getAttribute("id"));
            if(clickObj.innerHTML=="全部展开" && strObj.indexOf("child_")>-1 && allTR[i].style.display == 'none')
            {
                allTR[i].style.display='block';
            }else if(clickObj.innerHTML=="全部收起" && strObj.indexOf("child_")>-1 && strObj.split('_').length>3 && allTR[i].style.display == 'block')
            {
                allTR[i].style.display='none';
            }
        }
        if(clickObj.innerHTML=="全部展开")
        {                
            for(var j=0;j<trlength-1;j++)
            {
                var childrenArray = allTR[j].children;
                var childrenlength = childrenArray.length;
                
                for(var i = 0;i< childrenlength;i++)
                {
                    var clickA = WebForm_GetElementByTagName(childrenArray[i],"a");
                    if(clickA!=null)
                    {
                        clickA.outerHTML=clickA.outerHTML.replace(/展开/g,'收起');
                        break;
                    }
                }
             }
        }
        else if(clickObj.innerHTML=="全部收起")
        {             
            for(var j=0;j<trlength-1;j++)
            {
                var childrenArray = allTR[j].children;
                var childrenlength = childrenArray.length;
                
                for(var i = 0;i< childrenlength;i++)
                {
                    var clickA = WebForm_GetElementByTagName(childrenArray[i],"a");
                    if(clickA!=null)
                    {
                        clickA.outerHTML=clickA.outerHTML.replace(/收起/g,'展开');
                        break;
                    }
                }
             }
        }
    }
    //点击编辑参数
    function EditModel(clickObj,modelid,fatherid,pValue)
    {
        var pointX=event.clientX; 
        var pointY=event.clientY+document.documentElement.scrollTop+10;
        
        var divobj = document.getElementById("detailDiv");
        divobj.style.posTop = pointY;
        divobj.style.posLeft = pointX;
        divobj.style.display="block";
        
        document.getElementById("iptFatherid").setAttribute("value",fatherid);
        if(modelid == fatherid)//添加子类型
        {
            document.getElementById("Button_Update").setAttribute("disabled","true");
            document.getElementById("iptPropertyName").setAttribute("value","");
            document.getElementById("iptPropertyId").setAttribute("value","");
        }else
        {
            document.getElementById("iptPropertyName").setAttribute("value",clickObj.innerHTML);
            document.getElementById("iptPropertyValue").setAttribute("value",pValue);
            document.getElementById("iptPropertyId").setAttribute("value",modelid);
            document.getElementById("Button_Update").removeAttribute("disabled");
        }
    }
    function NewModel()
    {
        var pointX=event.clientX; 
        var pointY=event.clientY+document.documentElement.scrollTop+10;
        
        var divobj = document.getElementById("detailDiv");
        divobj.style.posTop = pointY;
        divobj.style.posLeft = pointX;
        divobj.style.display="block";
        
        document.getElementById("iptPropertyName").setAttribute("value","");
        document.getElementById("iptPropertyId").setAttribute("value","");
        document.getElementById("iptFatherid").setAttribute("value","0");
        document.getElementById("Button_Update").setAttribute("disabled","true");
    }
    function CheckParaAll(e,itemName)
    {
        var aa = document.getElementsByName(itemName);
        for (var i=0; i<aa.length; i++){
            aa[i].checked = e.checked;
        }
        var eall = document.getElementById("explanAllAchor");
        if(e.checked)
            eall.innerHTML="全部展开";
        else
            eall.innerHTML="全部收起";
        ExpandAll(eall);
        return;
    }
    
    function CheckParameterItem(e,allName,trid)
    {

      var all = document.getElementsByName(allName)[0];
       var aa = document.getElementsByName(e.name);
      if(!e.checked)//不选中,父类别与全选也不选中
      {
        all.checked = false;
        var trstr = new String(trid);
        var trstrArr = trstr.split('_');
        var tsstrArrlength = trstrArr.length;
        for(var j=0;j<tsstrArrlength;j++)
        {
            if(trstr.lastIndexOf('_') == -1)
                break;
            trstr = trstr.substring(0,trstr.lastIndexOf('_'));
            if(document.getElementById(trstr) == null)
                break;
            var childrenArray = document.getElementById(trstr).children;
            var childrenlength = childrenArray.length;
            for(var i = 0;i< childrenlength;i++)
            {
                var chk = WebForm_GetElementByTagName(childrenArray[i],"input");
                if(chk != null && chk.type!="checkbox")
                    continue;
                chk.checked =false;
                break;
             }
        }

      }
      else
      {
            var childrenArray = document.getElementById(trid).children;
            var childrenlength = childrenArray.length;
            for(var i = 0;i< childrenlength;i++)
            {
                var clickA = WebForm_GetElementByTagName(childrenArray[i],"a");
                if(clickA!=null)
                {
                    clickA.outerHTML=clickA.outerHTML.replace(/展开/g,'收起');
                    break;
                }
            }
            //选择所有子类别
            var allTR = document.getElementById("dataTable").rows;
            var trlength = allTR.length;
            var expandTRArr = new Array();
            for(var j=0;j<trlength;j++)
            {
                var strObj = new String(allTR[j].getAttribute("id"));
                if(strObj.indexOf(trid+"_") == 0)
                {
                
                var childrenArray = allTR[j].children;
                var childrenlength = childrenArray.length;
                for(var i = 0;i< childrenlength;i++)
                {
                    var chk = WebForm_GetElementByTagName(childrenArray[i],"input");
                    if(chk.type!="checkbox")
                        continue;
                    chk.checked =true;
                    allTR[j].style.display='block';
                    expandTRArr.push(allTR[j].id);
                    break;
                 }
                }
             }
             var epdTRLength = expandTRArr.length;
            for(var j=0;j<epdTRLength;j++)
            {
                var tmpTR = document.getElementById(expandTRArr[j]);
                var childrenArray = tmpTR.children;
                var childrenlength = childrenArray.length;
                
                for(var i = 0;i< childrenlength;i++)
                {
                    var clickA = WebForm_GetElementByTagName(childrenArray[i],"a");
                    if(clickA!=null)
                    {
                        clickA.outerHTML=clickA.outerHTML.replace(/展开/g,'收起');
                        break;
                    }
                }
            }
            //全选
            for (var i=0; i<aa.length; i++)                                    
            {
                if(!aa[i].checked) 
                    return;
            }
            all.checked = true;
      }
    }
    </script>

</head>
<body onkeydown="KeyClick('btnQueryNormal')">
    <form id="form1" runat="server" defaultbutton="DefaultButton">
        <div id="MainContentCommon">
            <%--<div class="tit" id="mcTitle" runat="server" title="testss">
                &gt;&gt;&gt;--%>
                <%--<asp:Label ID="lblTabName" runat="server" Width="665px" Visible="false"></asp:Label>--%>
            <%--</div>--%>
                <table cellpadding="0" cellspacing="0" style="background-color: lightsteelblue; width: 100%">
                    <tr>
                        <td>
                        <asp:Label ID="Label3" runat="server" Text="&gt;&gt;&gt;" CssClass="tit" Visible="false"></asp:Label>
                        <asp:Label ID="lblTabName" runat="server" Text="类型参数" CssClass="tit" Visible="false"></asp:Label>
                            <%--/*第一个控件btnDefaultSearch唯一的功能是聚焦focus用的，界面上看不见，但实际是可见的，
                            但是又不是Visible="false"(也就是隐藏后，就不能把focus聚在这个控件上了)
                            btnQuery_ServerClick处理函数就是那个查询按钮的处理函数
                            这样的结果就是，在输入查询条件的时候，可以直接按回车，运行的是第一个按钮，即调用查询，否则其他办法需要
                            鼠标点击其他空的地方，才能聚焦到查询按钮*/--%>
                            <asp:Button ID="btnDefaultSearch" runat="server" CssClass="nobuttonface" Text=""
                                OnClick="btnQuery_ServerClick" />                           
                            <asp:Button ID="BtnCustomSearch" runat="server" CssClass="flatbuttonface iconCustSearch" Text="复杂查询"
                                OnClick="BtnCustomSearch_Click" Visible="false"/>
                            <%--<asp:Button ID="btnNew" runat="server" CausesValidation="False" CssClass="flatbuttonface iconNew"
                                Text="新 建" onclick="NewModel()" EnableViewState="false" Visible="false" />--%>
                            <input type="button" id="BtnNew" name="btnNew" onclick="NewModel()" class="flatbuttonface iconNew"
                                value="新建类型" />
                            <asp:Button ID="BtnImport" runat="server" CausesValidation="False" CssClass="flatbuttonface iconImport"
                                Text="导入" OnClick="BtnImportClick" EnableViewState="false" Visible="true" />
                            <asp:Button ID="BtnExport" runat="server" CausesValidation="False" CssClass="flatbuttonface iconPrint"
                                Text="打印/导出 " UseSubmitBehavior="False" OnClick="Btn_Export" EnableViewState="false" Visible="true" />
                           <%--
                            <asp:Button ID="BtnExport" runat="server" CausesValidation="False" CssClass="flatbuttonface iconExport"
                                Text="导 出 " UseSubmitBehavior="False" OnClick="Btn_Export" EnableViewState="false" Visible="true" />
                           --%> <%--普通查询的"清空查询条件"--%>
                            <input id="BtnClear_S" runat="server" type="button" value="清空查询条件" class="flatbuttonface iconClear" onclick="ClearData();" visible="true" />
                             <%--自定义查询的"清空查询条件"--%>
                            <asp:Button ID="BtnClear_CS" runat="server" CssClass="flatbuttonface iconClear" Text="清空查询条件" OnClick="BtnClear_Click"
                                Visible="False" />                           
                           <%-- <asp:Button ID="BtnRemark" runat="server" CssClass="flatbuttonface iconComment" Text="表备忘" OnClick="BtnRemark_Click"
                                EnableViewState="false" />--%>
                               <%-- <input id="mschart" runat="server" type="button" class="flatbuttonface iconChart" value="统计图" onclick="location.href='MsChart.aspx'" visible="false" />
                                <input id="BtnPrint" runat="server" type="button" value="打 印" class="flatbuttonface iconPrint" onclick="Print(true);" visible="false" />
                                --%><%--<asp:Button ID="BtnPrint" runat="server" CausesValidation="False" CssClass="flatbuttonface iconPrint" Text="打 印" 
                                UseSubmitBehavior="False" EnableViewState="false" onclick="Print();" />   --%>                              
                            <asp:Button ID="DelButton" CausesValidation="False" runat="server" Text="选中删除" OnClick="DelButtonClick"
                                EnableViewState="false" OnClientClick="if(confirm('删除参数将一并删除选中参数的所有子参数,请慎重!'))return delDataMode();" CssClass="flatbuttonface iconDel"
                                Visible="true" />
                        </td>
                    </tr>
                </table>       
            <div class="con">
                <div id="QueryDiv">
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <table>
                                    <tbody id="tbQueryCls" runat="server" align="center">
                                    </tbody>
                                </table>
                            </td>
                            <td align="left">
                                <asp:Button ID="btnQueryNormal" runat="server" Text="查 询" Width="91px" CssClass="buttonface iconSearch"
                                    Style="margin: 5px 0px 5px 15px" OnClick="btnQuery_ServerClick" OnClientClick="return CheckQueryData();" />
                            <%--<input id="BtnClear_S" runat="server" type="button" value="清空查询条件" class="buttonface" onclick="ClearData();" />
                            --%></td>
                        </tr>
                    </table>
                    <table id="tbCustom" runat="server" visible="false" cellpadding="0" cellspacing="0">
                        <tr>
                            <td style="width: 149px; height: 18px">
                                列名：
                            </td>
                            <td style="width: 100px; height: 18px">
                                条件：
                            </td>
                            <td style="width: 54px; height: 18px">
                            </td>
                            <td style="width: 107px; height: 18px">
                                已添加条件：</td>
                        </tr>
                        <tr>
                            <td style="width: 149px">
                                <asp:ListBox ID="lbCustomColCode" runat="server" Height="159px" Width="188px"></asp:ListBox></td>
                            <td style="width: 100px">
                                <asp:ListBox ID="lbCustomOpr" runat="server" Height="159px" Width="117px" EnableViewState="false">
                                    <asp:ListItem Value="=" Text="等于"></asp:ListItem>
                                    <asp:ListItem Value="&gt" Text="大于"></asp:ListItem>
                                    <asp:ListItem Value="&lt" Text="小于"></asp:ListItem>
                                    <asp:ListItem Value="&gt;=" Text="大于等于"></asp:ListItem>
                                    <asp:ListItem Value="&lt;=" Text="小于等于"></asp:ListItem>
                                    <asp:ListItem Value="&lt&gt" Text="等于"></asp:ListItem>
                                    <asp:ListItem Value="like" Text="模糊匹配"></asp:ListItem>
                                </asp:ListBox></td>
                            <td style="width: 120px; margin-top:5px" align="center">
                                <input type="radio" value="and" name="radioWhere" checked />并且
                                <br />
                                <input type="radio" value="or"  name="radioWhere"/>或者
                                <br />
                                <img onclick="WdatePicker({el:'TBCustomNr'})" src="../../js/My97DatePicker/skin/datePicker.gif"
                                    width="16" height="22" align="absmiddle" title="输入时间">
                                <br />
                                输入值：
                                <br />
                                <asp:TextBox ID="TBInptValue" runat="server" Height="19px" Width="86px"></asp:TextBox>
                                <asp:Button ID="BtnCustomAdd" runat="server" Text="添 加" Width="91px" CssClass="buttonface iconAdd"
                                    Height="21px" OnClick="BtnCustomAdd_Click" EnableViewState="false" />
                                <asp:Button ID="btnQueryCustom" runat="server" Visible="false" Text="查 询" Width="91px"
                                    CssClass="buttonface iconSearch" OnClick="BtnCustomSearchOpr_Click" />
                                <asp:HiddenField ID="hidCustomWhere" runat="server" />
                            </td>
                            <td style="width: 377px;height:159px; border:solid 1px gray; vertical-align:top">
                                <%--<asp:Label ID="tbCustomSel" runat="server" Height="159px" BorderColor="gray" BorderStyle="solid" BorderWidth="1" Width="377px" Text="" CssClass="condition"></asp:Label>--%>&nbsp;
                                <asp:Literal Text="" runat="server" ID="tbCustomSel"></asp:Literal>
                                
                             </td>
                        </tr>
                    </table>
                </div>
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            <%--<asp:Button ID="BtnCustomSearch" runat="server" CssClass="buttonface" Text="自定义查询"
                                OnClick="BtnCustomSearch_Click" />--%>
                            <%--<input type="button" id="btnNew" name="btnNewd" onclick="NewModel()" class="buttonface"
                                value="新建" />
                            <asp:Button ID="BtnImport" runat="server" CausesValidation="False" CssClass="buttonface"
                                Text="导 入" OnClick="BtnImportClick" />--%>
                           <%-- <asp:Button ID="BtnExport" runat="server" CausesValidation="False" CssClass="buttonface"
                                Text="导 出 " UseSubmitBehavior="False" OnClick="Btn_Export" />--%>
                            <%--<asp:Button ID="BtnClear_CS" runat="server" CssClass="buttonface" Text="清空查询条件" OnClick="BtnClear_Click"
                                Visible="False" />--%>
                           <%-- &nbsp;<asp:Button ID="BtnRemark" runat="server" CssClass="buttonface" Text="备忘"
                                OnClick="BtnRemark_Click" />--%>
                        </td>
                    </tr>
                </table>
                <table id="dataTable" class="CommonPage_table" cellspacing="0" cellpadding="0" style=" table-layout:fixed">
                    <tbody id="tab_content" runat="server" align="center">
                    </tbody>
                </table>
            </div>
                <table class="CommonPage_Pagetable" cellspacing="0" cellpadding="0">
                <tbody runat="server">
                    <tr>
                        <td align="left" style="height: 18px">
                            <%--<asp:Button ID="DelButton" CausesValidation="False" runat="server" Text="选中删除" OnClick="DelButtonClick"
                                EnableViewState="true" CssClass="buttonface" Visible="false" OnClientClick="if(confirm('删除参数将一并删除选中参数的所有子参数,请慎重!'))return delDataMode();" />
                            --%>第<asp:Label ID="lblCpi" runat="server" Text="1"></asp:Label>页&nbsp; 共<asp:Label ID="lblallPage"
                                runat="server" Text="1"></asp:Label>页&nbsp; 每页<asp:TextBox ID="txtRowinOnePage" runat="server"
                                    Width="20px" OnTextChanged="txtRowinOnePage_TextChanged" AutoPostBack="true" Text="20"></asp:TextBox>条&nbsp;
                            共<asp:Label ID="lblAllRow" runat="server" Text="Label"></asp:Label>条
                        </td>
                        <td align="right" style="height: 18px">
                            <asp:Label ID="Label1" runat="server" Text="跳到第"></asp:Label>
                            <asp:TextBox ID="JumpPage" runat="server" AutoPostBack="True" OnTextChanged="JumpPageTextChanged"
                                Width="47px"></asp:TextBox>&nbsp; 页
                            <asp:LinkButton ID="LbtFirstPage" runat="server" OnClick="FirstPageClick">首页</asp:LinkButton>&nbsp;
                            <asp:LinkButton ID="LbtPreviousPage" runat="server" OnClick="PreviousPageClick">上一页</asp:LinkButton>&nbsp;
                            <asp:LinkButton ID="LbtNextPage" runat="server" OnClick="NextPageClick">下一页</asp:LinkButton>&nbsp;
                            <asp:LinkButton ID="LbtLastPage" runat="server" OnClick="LastPageClick">尾页</asp:LinkButton>&nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div>
            <asp:Button ID="DefaultButton" Style="display: none" runat="server" Text="默认" UseSubmitBehavior="false"
                OnClientClick="doDefaultAction(this.form); return false;" />
            <asp:Button ID="SearchButton" Style="display: none" runat="server" Text="查询" OnClick="SearchButtonClick" />
            <asp:Button ID="BtnOpenDiag" Style="display: none" runat="server" Text="Button" />
            <asp:Button ID="SortButton" Style="display: none" runat="server" Text="排序" OnClick="SortButtonClick" />
            <asp:TextBox ID="txtQueryCls" Style="display: none" runat="server"></asp:TextBox>
            <asp:HiddenField ID="txtQueryData" runat="server" />
            <input type="hidden" id="hidDelIds" name="hidDelIds" value="" />
            <asp:HiddenField ID="Txt_mysql" runat="server" Value="" />
            <asp:HiddenField ID="SortTxt" runat="server" Value="" />
        </div>
        <div id="detailDiv" style="display: none; position: absolute">
        <div id="GerneralDivNoBorder">
            <table cellpadding="0" cellspacing="3">
                <tr>
                    <td align="center" nowrap>
                        属性名
                    </td>
                    <td align="left">
                        <input type="text" id="iptPropertyName" name="iptPropertyName" style="width: 250px"
                            maxlength="100" />
                        <input type="hidden" id="iptPropertyId" name="iptPropertyId" />
                        <input type="hidden" id="iptFatherid" name="iptFatherid" />
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        属性值
                    </td>
                    <td align="left">
                        <input type="text" id="iptPropertyValue" name="iptPropertyValue" style="width: 250px"
                            maxlength="100" />
                    </td>
                </tr>
                <tr >      
                <td align="left" >                        
                        <asp:Label ID="Label2" runat="server" Text="提示："></asp:Label>
                    </td>              
                    <td align="left">                        
                        <asp:Label ID="Label11" runat="server" Width="250px" Text="增加类型的时候，属性值建议用从1（或者0)开始的整数,修改的时候不随意修改属性值！"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2" style="padding-top: 5px">
                        <asp:Button ID="Button_Update" runat="server" CssClass="buttonface" OnClick="ButtonUpdate_Click"
                            Text="修改" />
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
                        <asp:Button ID="Button_Insert" runat="server" CssClass="buttonface" Text="新增" OnClick="Button_Insert_Click" />
                        &nbsp;&nbsp;&nbsp;
                        <input type="button" class="buttonface" value="关闭" onclick="document.getElementById('detailDiv').style.display='none'" />
                    </td>
                </tr>
            </table>
            </div>
        </div>
    </form>
</body>
</html>
